package com.sgb.knowledgeshare.viewmodel;

import androidx.lifecycle.ViewModel;
import com.sgb.knowledgeshare.ShareConfig;
import com.sgb.knowledgeshare.entity.ShareUserInfoEntity;
import com.sgb.knowledgeshare.view.activity.ShareMinFansActivity;
import com.swgk.core.base.api.ICallBack;
import com.swgk.core.base.model.entity.BaseEntity;
import com.swgk.core.util.MToast;
import java.util.HashMap;
import java.util.Map;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

/**
 * Created by fq on 2020/9/11 0011
 * Description：
 */
public class ShareMinFansModel extends ViewModel {

    ShareMinFansActivity activity;
    public void setActivity(ShareMinFansActivity shareMinFansActivity) {
        activity = shareMinFansActivity;
    }

    /**
     * 获取用户信息
     * @param userid
     */
    public void getUserHomePage(String userid) {
        Map map = new HashMap();
        map.put("userNo",userid );
        ShareConfig.getInstance().getApi().getUserHomePage(map).enqueue(new ICallBack<BaseEntity<ShareUserInfoEntity>>() {
            @Override
            public void onSuccess(BaseEntity<ShareUserInfoEntity> data) {
                if (data.getData() == null) {
                    return;
                }
                if (data.getState().equals(ShareConfig.RESPONSE_OK)) {
                    activity.setUserData(data.getData());
                }
            }
        });
    }


}
